package jk.spider.core.task.threading;

import java.util.concurrent.TimeUnit;

import jk.spider.core.SpiderController;

import org.apache.log4j.Logger;

public abstract class MonitorThread extends Thread {
	private static final Logger log = Logger.getLogger(MonitorThread.class);
    protected int interval ;
    protected SpiderController controller;

    public MonitorThread ( SpiderController controller, int interval, int tCount) {
    	super ( " Monitor Thread " + tCount );
        this.controller = controller;
        this.interval = interval;
    }

    public abstract void doMonitorTask ( );
    

	public void run() {
		while ( true ) {
            try {
                this.doMonitorTask();
                TimeUnit.SECONDS.sleep(interval);
            } catch (InterruptedException e) {
            	log.error("MonitorThread InterruptedException", e);
                Thread.currentThread().interrupt();
            }
        }
	}
}
